package com.hedl.practice.diyJava.reflex.study_01.tmp02;

import java.util.Random;

//继承自抽象的学生类
public class Ordinary extends Student{
    public Ordinary(){}
    public Ordinary(String name){
        super(name);
    }

    public void write(String title){
        setTitle(title);

        //给作文打分
        int[] scores = {5,10,15,20};
        Random random = new Random();
        setScore(scores[random.nextInt(3) + 0]);
    }

    public void eat(){
        System.out.println("今天"+getFoods().day+",我吃了"+getFoods());
    }

    public String toString(){
        return "写了一篇作文《"+getTitle()+"》，得分"+getScore();
    }
}
